<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="ZhangBin">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title>微信授权拉取用户信息</title>
    <link rel="shortcut icon" href="/static/img/Head.png" type="image/x-icon"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
    <table class="table">
        <caption>微信授权拉取用户信息</caption>
        <tbody>
        <tr class="active">
            <td>头像</td>
            <td></td>
        </tr>
        <tr class="success">
            <td>昵称</td>
            <td></td>
        </tr>
        <tr class="warning">
            <td>性别</td>
            <td></td>
        </tr>
        <tr class="success">
            <td>地域</td>
            <td></td>
        </tr>
        <tr class="danger">
            <td>语言</td>
            <td></td>
        </tr>
        </tbody>
    </table>
</div>
<!--footer:END -->
<script type="text/javascript" src="/static/plugins/jQuery/jquery-3.3.1.min.js"></script>
<script>
    $.ajax({
        url: "https://zhangbin.xin/wxOAuth/getUserInfo.zb",
        type: "get",
        dataType: "JSON",
        success: function (info) {
            if (info) {
                var $tr = $("tbody tr");
                $tr.eq(0).find("td").eq(1).append("<img src='" + info.headimgurl + "' height='50'/>");
                $tr.eq(1).find("td").eq(1).text(info.nickname);
                $tr.eq(2).find("td").eq(1).text(info.sex == 1 ? "男" : info.sex == 2 ? "女" : "未知");
                $tr.eq(3).find("td").eq(1).text(info.country + " " + info.province + " " + info.city);
                $tr.eq(4).find("td").eq(1).text(info.language);
            }
        }, error: function () {
            alert("获取用户信息出错了哦！")
        }
    })
</script>
</body>
</html>
